#pragma once
#include "Types.h"
#include <math.h>




namespace Boon
{
	const float PI = 3.1415926535897932384626433f;
	const float RadiansToDegree = 360 / ( PI * 2.0f );
	const float DegreeToRadians = ( PI * 2.0f ) / 360.0f;

	/*! \brief		Clamps a value between a minimum and maximum value.
	*/
	template<typename T>
	inline T Clamp( const T& value, const T& minimum, const T& maximum )
	{
		return Min( Max( value, minimum ), maximum );
	}
	
	/*! \brief		Interpolates between a and b by t. t is clamped between 0 and 1.
					When t = 0 it returns from. When t = 1 it returns to.
					When t = 0.5 returns the average of from and to.
	\return			Lerped value by T between from and to
	*/
	template<typename T>
	inline T Lerp( const T& from, const T& to, float t )
	{
		return ( from + ( Clamp( t, .0f, 1.0f ) * ( to - from ) ) );
	}

	template<typename T>
	inline T Min( const T& a, const T& b )
	{
		if( a < b ) return a;
		return b;
	}

	template<typename T>
	inline T Max( const T& a, const T& b )
	{
		if( a > b ) return a;
		return b;
	}

	inline uint_32 Log2( uint_32 n )
	{
		int index = 0;
		while ( n >>= 1 ) ++index;
		return index;
	}

	template <typename T>
	int Sign( T val )
	{
		return ( T(0) < val ) - ( val < T(0) );
	}
}